<header />
<bstablecss />

<body class="boxed">

<div class="body">

    <!--header start-->
    <!--导航部分-->
    <include file="Common/header_nav" />
    <!--/导航部分-->
    <!-- /end header -->

    <div class="container">

        <div class="row-fluid">

            <div class="col-md-12  ">

                <section class="panel">

                    <div class="panel-heading">报告列表（不属于组织的普通用户）</div>
                    <div class="panel-body">
                        <label>点击选择问卷</label>
                        <select class="form-control" id="quiz_list_select">
                            <foreach name="quiz_list" item="quiz">
                                <option>{$quiz.quiz_name}</option></foreach>
                        </select>

                        <div id="toolbar"></div>

                        <table class="table table-striped no-margin table-bordered" id="user-report-table">

                        </table>
                    </div>
                    <div class="panel-footer ">
                        <a class="btn btn-success" href="/Home/Admin/showSingleUserGroupReport">查看综合报告</a>
                        <a class="btn btn-success" href="/Home/Admin/downloadSingleUserGroupReportPdf">下载pdf</a>
                    </div>
                </section>

            </div>

        </div>
    </div>

    <!--footer start-->
    <include file="Common/footer" />
    <!--footer end-->
</div></body></html>

<bstablejs />
<script src="__PUBLIC__/js/tableTools.js"></script>
<script>

    var tabletool = new TableTools();
    $(document).ready(function(){

        loadReport();

        $("#quiz_list_select").change(function(){
            loadReport();
        });

        function loadReport()
        {
            function QueryParams(para){
                var querydata = {
                    quiz_name: $("#quiz_list_select").val()
                };
                return querydata;
            }
            //表格列信息
            function columns(){
                return [
                    {
                        field: 'uid',
                        checkbox: true
                    },
                    {
                        field:'username',
                        title:'用户名'

                    },
                    {
                        field:'email',
                        title:'邮箱'
                    },
                    {
                        field:'age',
                        title:'年龄'
                    },
                    {
                        field:'sex',
                        title:'性别'
                    },
                    {   field:'user_id',
                        title:'操作',
                        formatter:Formatter
                    }];
            }

            function Formatter(value, row, index)
            {
                console.log(value);
                var quiz_name = $("#quiz_list_select").val();
                // alert("__URL__/showUserReport/quiz_name/"+quiz_name+'/uid/'+value);

                var href = "__URL__/showUserReport/quiz_name/"+quiz_name+'/uid/'+value;

                var seeReport = '<a class="btn btn-success btn-sm mg-r-sm" target="_blank" href='+href+'>查看报告</a>';

                href = "__URL__/deleteReport/quiz_name/"+quiz_name+'/uid/'+value;

                var deleteReport = '<a class="btn btn-danger btn-sm mg-r-sm" href='+href+'>删除报告</a>';

                href = "__URL__/downloadPdf/quiz_name/"+quiz_name+'/uid/'+value;

                var pdf = '<a class="btn btn-success btn-sm  mg-r-sm" target="_blank" href='+href+'>下载pdf</a>';


                return seeReport+pdf+deleteReport;
            }

            tabletool.bstable("user-report-table", "/TestAdmin/QuizResult/getNormalUserReportList",columns(), QueryParams, null);
        }





    });

</script>